const Utils = require("./Utils.js")

Utils.init()

let wrongFlag = true
// 关闭好友协助申请
threads.start(() => {
  while (wrongFlag) {
    sleep(30 * 1000)
    Utils.findPhotoTap("叉号", 0.8, [1750, 160, 160, 160])
  }
})

let seconds = 0
let num = 0
let flag = true
while (flag) {
  sleep(1000)
  if (Utils.findPictureTap("准备")) {
    num++
    if (num === 1) seconds = 600
    else seconds = 40
    Utils.waitTime(seconds)
    if (num != 4) {
      while (!Utils.findPicture("准备")) {
        sleep(1000)
        seconds += 2
        log("已等待 " + seconds + " 秒")
      }
    }
  }
  log("已等待 " + ++seconds + " 秒")
  if (Utils.findPictureTap("胜利")) {
    log("阴界之门 - 成功")
    Utils.tapPicture("返回二")
    Utils.tapPicture("返回一")
    flag = false
  }
}

wrongFlag = false